class Animal{
    public String name;
    public int age;

    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }
    public void eat(){
        System.out.println("eat()");
    }

}
class Dog extends Animal{
    public Dog(String name,int age){
        super(name,age);//显示调用构造方法,必须放在第一行，不能出现在静态方法中
    }
}
class Bird extends Animal{
    public String wing;
    public Bird(String name,int age,String wing){
        super(name,age);
        this.wing="飞翔";
    }
    public void fly(){
        System.out.println(name+"fly()");

    }
}
public class TestDemo {
    public static void main(String[] args) {
        Dog dog=new Dog("haha",22);
        dog.name="haha";
        System.out.println(dog.name);
        dog.eat();

        Bird bird=new Bird("heihei",21,"飞翔");
        bird.name="heihei";
        System.out.println(bird.name);
        bird.eat();
        bird.fly();
    }
}



























